// 最大子数组和
var maxSubArray = function(nums) {
    let maxSum = nums[0]
    let dp = [], n = nums.length;
    for (let i = 0; i < n; i++) {
        dp[i] = 0;
    }
    dp[0] = nums[0]
    for (let i = 1; i < n; i++) {
        dp[i] = Math.max(nums[i], dp[i - 1] + nums[i]);
        maxSum = Math.max(maxSum, dp[i]);
    }
    return maxSum;
};